#ifndef RANGELIST_H
#define RANGELIST_H

#include <sys/types.h>

typedef struct {
	off_t from;
	off_t to;
} range_t;

typedef struct {
	range_t *ranges;
	size_t size;
	size_t used;
} rangelist_t;

void rangelist_init (rangelist_t *rangelist);
void rangelist_free (rangelist_t *rangelist);

void rangelist_reset (rangelist_t *rangelist);

int rangelist_load (rangelist_t *rangelist, const char *string, size_t len, off_t filesize);

int rangelist_add_range (rangelist_t *rangelist, off_t from, off_t to, off_t filesize);

off_t rangelist_get_bytes (rangelist_t *rangelist);

void rangelist_print (rangelist_t *rangelist);

#endif /* RANGELIST_H */
